package com.wanke.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wanke.bean.CheckinDormitoryRecordBean;
import com.wanke.bean.QueryCheckDormitoryCondition;
import com.wanke.dao.BanjiDao;
import com.wanke.dao.BaseDao;
import com.wanke.dao.CheckinCourseDao;
import com.wanke.dao.CheckinDormitoryDao;
import com.wanke.dao.CourseDao;
import com.wanke.dao.DormitoryDao;
import com.wanke.dao.StudentDao;
import com.wanke.dao.TeacherDao;
import com.wanke.entity.Banji;
import com.wanke.entity.CheckinDormitory;
import com.wanke.entity.Dormitory;
import com.wanke.entity.Student;
import com.wanke.entity.Teacher;

@Service("dormitoryService")
@Transactional
public class DormitoryServiceImpl implements DormitoryService {
	@Resource(name = "baseDao")
	BaseDao baseDao;

	@Resource(name = "banjiDao")
	BanjiDao banjiDao;

	@Resource(name = "checkinCourseDao")
	CheckinCourseDao checkinCourseDao;

	@Resource(name = "checkinDormitoryDao")
	CheckinDormitoryDao checkinDormitoryDao;

	@Resource(name = "courseDao")
	CourseDao courseDao;

	@Resource(name = "dormitoryDao")
	DormitoryDao dormitoryDao;

	@Resource(name = "studentDao")
	StudentDao studentDao;

	@Resource(name = "teacherDao")
	TeacherDao teacherDao;

	/**
	 * 耀锋
	 * 
	 * Map<String, Object> result = new HashMap<>(); try { boolean flag =
	 * dormitoryDao.addDormitory(dormitory); if (flag==true) {
	 * result.put("result", "success"); }else { result.put("result", "fail"); }
	 * } catch (Exception e) { e.printStackTrace(); } return result;
	 */
	@Override
	public Map<String, Object> addDormitory(Dormitory dormitory, String counselor_id) {
		Map<String, Object> result = new HashMap<>();
		try {
			dormitory.setTeacher(findCounselorById(counselor_id));
			boolean flag = dormitoryDao.addDormitory(dormitory);
			if (flag == true) {
				result.put("result", "success");
			} else {
				result.put("result", "fail");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public Map<String, Object> updateDormitory(Dormitory dormitory) {
		Map<String, Object> result = new HashMap<>();
		try {
			boolean flag = dormitoryDao.updateDormitory(dormitory);
			if (flag == true) {
				result.put("result", "success");
			} else {
				result.put("result", "fail");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public Teacher findCounselorById(String counselor_id) {
		Teacher teacher = teacherDao.findById(Integer.parseInt(counselor_id));
		return teacher;
	}

	@Override
	public List<Student> findMembersByDormitoryId(int dormitory_id) {
		Dormitory dormitory = dormitoryDao.findById(dormitory_id);
		List<Student> members = studentDao.findByDormitory(dormitory);
		return members;
	}

	@Override
	public Student findStudentByStudentId(int student_id) {
		Student student = new Student();
		try {
			student = studentDao.findById(student_id);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return student;
	}

	@Override
	public Map<String, Object> getCheckingDormitoryInfo(int student_id) {
		Map<String, Object> result = new HashMap<>();
		Map<String, Object> member_info = new HashMap<>();
		Student head_student = findStudentByStudentId(student_id);
		Dormitory dormitory = head_student.getDormitory();
		List<Student> members = findMembersByDormitoryId(dormitory.getId());
		for (int i = 0; i < members.size(); i++) {
			Map<String, Object> info = new HashMap<>();
			info.put("student_id", members.get(i).getId());
			info.put("student_name", members.get(i).getName());
			info.put("parent_phone", members.get(i).getParentPhone());

			info.put("banji_id", members.get(i).getBanji().getId());
			info.put("banji_name", members.get(i).getBanji().getName());

			info.put("head_teacher_id", members.get(i).getBanji().getTeacher().getId());
			info.put("head_teacher_name", members.get(i).getBanji().getTeacher().getName());
			info.put("head_teacher_phone", members.get(i).getBanji().getTeacher().getPhone());

			member_info.put("member_" + i, info);
		}

		result.put("members", member_info);
		result.put("counselor_id", dormitory.getTeacher().getId());
		result.put("counselor_name", dormitory.getTeacher().getName());
		result.put("counselor_phone", dormitory.getTeacher().getPhone());
		result.put("head_student_id", head_student.getId());
		result.put("head_student_name", head_student.getName());
		result.put("dormitory_id", dormitory.getId());
		result.put("dormitory_zoom1", dormitory.getZoom1());
		result.put("dormitory_zoom2", dormitory.getZoom2());
		result.put("dormitory_zoom3", dormitory.getZoom3());
		return result;
	}

	@Override
	public Map<String, Object> addDormitoryCheckIn(int student_id, String result) {
		Map<String, Object> map = new HashMap<>();
		Student student = studentDao.findById(student_id);
		// System.out.println(getClass().toString() + "-->" +
		// student.toString());

		Dormitory dormitory = student.getDormitory();
		CheckinDormitory checkinDormitory = new CheckinDormitory();
		checkinDormitory.setResult(result);
		checkinDormitory.setTime(new Date());
		checkinDormitory.setDormitoryId(dormitory.getId());
		checkinDormitoryDao.saveCheckinDormitory(checkinDormitory);
		checkinDormitory = (CheckinDormitory) checkinDormitoryDao.findByExample(checkinDormitory).get(0);
		// System.out.println(getClass().toString() + "-->" +
		// checkinDormitory.toString());

		Set<Student> students = new HashSet<>();
		Set<CheckinDormitory> checkinDormitories = new HashSet<>();

		students.add(student);
		checkinDormitories.add(checkinDormitory);

		student.setCheckinDormitories(checkinDormitories);
		checkinDormitory.setStudents(students);

		student.getCheckinDormitories().add(checkinDormitory);
		checkinDormitory.getStudents().add(student);

		boolean result_student = studentDao.updateStudent(student);
		boolean result_checkin = checkinDormitoryDao.updateCheckinDormitory(checkinDormitory);

		if (result_checkin && result_student) {
			map.put("result_code", 1);
			map.put("result", "success");
		} else if (result_checkin == false) {
			map.put("result_code", 2);
			map.put("result", "error_checkin_dormitory");
		} else if (result_student == false) {
			map.put("result_code", 3);
			map.put("result", "error_student");
		} else if (result_student || result_checkin) {
			map.put("result_code", 4);
			map.put("result", "error_both");
		}
		return map;
	}

	@Override
	public List<CheckinDormitoryRecordBean> getCheckinDataAsTeacher(Teacher teacher) {
		List<CheckinDormitoryRecordBean> result = new ArrayList<>();

		switch (Integer.parseInt(teacher.getType())) {
		case 1:
			// 班主任
			result = getCheckinDataAsTeacherType1(result, teacher);
			break;
		case 2:
			// 宿管员
			result = getCheckinDataAsTeacherType2(result, teacher);
			break;
		case 3:
			// 超级用户
			result = getCheckinDataAsTeacherType3(result, teacher);
			break;
		case 4:
			// 超级管理员
			result = getCheckinDataAsTeacherType3(result, teacher);
			break;

		default:
			// 拒绝访问
			break;
		}
		System.out.println(getClass().toString() + "-->" + result.toString() + "-->" + result.size());
		return result;
	}

	@Override
	public List<CheckinDormitoryRecordBean> getCheckinDataAsTeacherType1(List<CheckinDormitoryRecordBean> result,
			Teacher teacher) {
		try {
			Teacher head_teacher = teacherDao.findById(teacher.getId());
			Set<Banji> banjis = head_teacher.getBanjis();
			for (Banji banji : banjis) {
				Set<Student> students = banji.getStudents();
				for (Student student : students) {
					Set<CheckinDormitory> cds = student.getCheckinDormitories();
					Dormitory dormitory = student.getDormitory();
					Teacher counselor = dormitory.getTeacher();
					for (CheckinDormitory cd : cds) {

						result.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd, teacher.getType()));
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public List<CheckinDormitoryRecordBean> getCheckinDataAsTeacherType2(List<CheckinDormitoryRecordBean> result,
			Teacher teacher) {
		try {
			System.out.println(getClass().toString() + "-->" + "as counselor");
			Teacher counselor = teacherDao.findById(teacher.getId());
			Set<Dormitory> dormitories = counselor.getDormitories();
			for (Dormitory dormitory : dormitories) {
				Set<Student> students = dormitory.getStudents();
				for (Student student : students) {
					Banji banji = student.getBanji();
					Teacher head_teacher = banji.getTeacher();
					Set<CheckinDormitory> cds = student.getCheckinDormitories();
					for (CheckinDormitory cd : cds) {

						result.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd, teacher.getType()));
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public List<CheckinDormitoryRecordBean> getCheckinDataAsTeacherType3(List<CheckinDormitoryRecordBean> result,
			Teacher teacher) {
		try {
			List<CheckinDormitory> checkinDormitories = checkinDormitoryDao.findAllCheckinDormitory();
			for (CheckinDormitory cd : checkinDormitories) {
				Set<Student> students = cd.getStudents();
				for (Student student : students) {
					Banji banji = student.getBanji();
					Dormitory dormitory = student.getDormitory();
					Teacher counselor = dormitory.getTeacher();
					Teacher head_teacher = banji.getTeacher();

					Set<CheckinDormitory> cds = student.getCheckinDormitories();

					// CheckinDormitoryRecordBean cdrb = new
					// CheckinDormitoryRecordBean();
					// cdrb.setStudent_id(student.getId());
					// cdrb.setStudent_name(student.getName());
					// cdrb.setStudent_phone(student.getPhone());
					// cdrb.setDormitory_id(dormitory.getId());
					// cdrb.setZoom_1(dormitory.getZoom1());
					// cdrb.setZoom_2(dormitory.getZoom2());
					// cdrb.setZoom_3(dormitory.getZoom3());
					// cdrb.setCounselor_id(counselor.getId());
					// cdrb.setCounselor_name(counselor.getName());
					// cdrb.setCounselor_phone(counselor.getPhone());
					// cdrb.setHead_teacher_id(head_teacher.getId());
					// cdrb.setHead_teacher_name(head_teacher.getName());
					// cdrb.setHead_teacher_phone(head_teacher.getPhone());
					// cdrb.setBanji_id(banji.getId());
					// cdrb.setBanji_name(banji.getName());
					// cdrb.setCheckin_id(cd.getId());
					// cdrb.setCheckin_time(cd.getTime());
					// cdrb.setCheckin_result(cd.getResult());
					// cdrb.setIdentity_type(Integer.parseInt(teacher.getType()));

					result.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd, teacher.getType()));
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public CheckinDormitoryRecordBean makeCDRB(Student student, Dormitory dormitory, Teacher counselor,
			Teacher head_teacher, Banji banji, CheckinDormitory cd, String identity_type) {
		CheckinDormitoryRecordBean cdrb = new CheckinDormitoryRecordBean();
		cdrb.setStudent_id(student.getId());
		cdrb.setStudent_name(student.getName());
		cdrb.setStudent_phone(student.getPhone());
		cdrb.setDormitory_id(dormitory.getId());
		cdrb.setZoom_1(dormitory.getZoom1());
		cdrb.setZoom_2(dormitory.getZoom2());
		cdrb.setZoom_3(dormitory.getZoom3());
		cdrb.setCounselor_id(counselor.getId());
		cdrb.setCounselor_name(counselor.getName());
		cdrb.setCounselor_phone(counselor.getPhone());
		cdrb.setHead_teacher_id(head_teacher.getId());
		cdrb.setHead_teacher_name(head_teacher.getName());
		cdrb.setHead_teacher_phone(head_teacher.getPhone());
		cdrb.setBanji_id(banji.getId());
		cdrb.setBanji_name(banji.getName());
		cdrb.setCheckin_id(cd.getId());
		cdrb.setCheckin_time(cd.getTime());
		cdrb.setCheckin_result(cd.getResult());
		cdrb.setIdentity_type(Integer.parseInt(identity_type));

		return cdrb;
	}

	@Override
	public List<CheckinDormitoryRecordBean> screenCheckinData(QueryCheckDormitoryCondition condition) {
		List<CheckinDormitoryRecordBean> result = new ArrayList<>();
		int identity_type = condition.getIdentity_type();
		int query_type = condition.getQuery_type();
		int teacher_id = condition.getTeacher_id();

		// Teacher get_alldata_condition = new Teacher();
		// get_alldata_condition.setId(teacher_id);
		// get_alldata_condition.setType(identity_type + "");
		// List<CheckinDormitoryRecordBean> cdrbs =
		// getCheckinDataAsTeacher(get_alldata_condition);
		// List<CheckinDormitoryRecordBean> screenedData = new ArrayList<>();

		switch (identity_type) {
		case 1:
			// 班主任
			result = getCheckinDataAsTeacherType1WithCondition(condition);
			break;
		case 2:
			// 宿管员
			result = getCheckinDataAsTeacherType2WithCondition(condition);
			break;
		case 3:
			// 超级用户
			result = getCheckinDataAsTeacherType3WithCondition(condition);
			break;

		case 4:
			// 超级管理员
			break;

		default:
			// 拒绝访问
			break;
		}

		return result;
	}

	@Override
	public List<CheckinDormitoryRecordBean> getCheckinDataAsTeacherType1WithCondition(
			QueryCheckDormitoryCondition condition) {
		List<CheckinDormitoryRecordBean> cdrbs = new ArrayList<>();
		String condition_semester = condition.getSemester();
		String condition_student_name = condition.getStudent_name();
		if (condition.getQuery_type()==1) {
			// 查询日常数据
			if ((condition_student_name != null) && (condition_student_name != "")) {
				// 有输入学生姓名
				List<CheckinDormitory> cds = checkinDormitoryDao.findByTimeBanjiNameAsType1(condition);
				for (CheckinDormitory cd : cds) {
					Set<Student> students = cd.getStudents();
					for (Student student : students) {
						Banji banji = student.getBanji();
						Teacher head_teacher = banji.getTeacher();
						Dormitory dormitory = student.getDormitory();
						Teacher counselor = dormitory.getTeacher();
						cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd,
								condition.getQuery_type().toString()));
					}
				}
			} else {
				// 无输入学生姓名
				List<CheckinDormitory> cds = checkinDormitoryDao.findByTimeBanjiAsType1(condition);
				for (CheckinDormitory cd : cds) {
					Set<Student> students = cd.getStudents();
					for (Student student : students) {
						Banji banji = student.getBanji();
						Teacher head_teacher = banji.getTeacher();
						Dormitory dormitory = student.getDormitory();
						Teacher counselor = dormitory.getTeacher();
						cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd,
								condition.getQuery_type().toString()));
					}
				}
			}

		} else {
			// 查询学期数据
			if ((condition_student_name != null) && (condition_student_name != "")) {
				// 有输入学生姓名
				List<CheckinDormitory> cds = checkinDormitoryDao.findBySemesterNameAsType1(condition);
				for (CheckinDormitory cd : cds) {
					Set<Student> students = cd.getStudents();
					for (Student student : students) {
						Banji banji = student.getBanji();
						Teacher head_teacher = banji.getTeacher();
						Dormitory dormitory = student.getDormitory();
						Teacher counselor = dormitory.getTeacher();
						cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd,
								condition.getQuery_type().toString()));
					}
				}
			} else {
				// 无输入学生姓名
				List<CheckinDormitory> cds = checkinDormitoryDao.findBySemesterAsType1(condition);
				for (CheckinDormitory cd : cds) {
					Set<Student> students = cd.getStudents();
					for (Student student : students) {
						Banji banji = student.getBanji();
						Teacher head_teacher = banji.getTeacher();
						Dormitory dormitory = student.getDormitory();
						Teacher counselor = dormitory.getTeacher();
						cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd,
								condition.getQuery_type().toString()));
					}
				}
			}
		}
		return cdrbs;
	}

	@Override
	public List<CheckinDormitoryRecordBean> getCheckinDataAsTeacherType2WithCondition(
			QueryCheckDormitoryCondition condition) {
		List<CheckinDormitoryRecordBean> cdrbs = new ArrayList<>();
		String condition_semester = condition.getSemester();
		String condition_student_name = condition.getStudent_name();
		if (condition.getQuery_type()==1) {
			// 查询日常数据
			if ((condition_student_name != null) && (condition_student_name != "")) {
				// 有输入学生姓名
				List<CheckinDormitory> cds = checkinDormitoryDao.findByTimeBanjiNameAsType2(condition);
				for (CheckinDormitory cd : cds) {
					Set<Student> students = cd.getStudents();
					for (Student student : students) {
						Banji banji = student.getBanji();
						Teacher head_teacher = banji.getTeacher();
						Dormitory dormitory = student.getDormitory();
						Teacher counselor = dormitory.getTeacher();
						cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd,
								condition.getQuery_type().toString()));
					}
				}
			} else {
				// 无输入学生姓名
				List<CheckinDormitory> cds = checkinDormitoryDao.findByTimeBanjiAsType2(condition);
				for (CheckinDormitory cd : cds) {
					Set<Student> students = cd.getStudents();
					for (Student student : students) {
						Banji banji = student.getBanji();
						Teacher head_teacher = banji.getTeacher();
						Dormitory dormitory = student.getDormitory();
						Teacher counselor = dormitory.getTeacher();
						cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd,
								condition.getQuery_type().toString()));
					}
				}
			}

		} else {
			// 查询学期数据
			if ((condition_student_name != null) && (condition_student_name != "")) {
				// 有输入学生姓名
				List<CheckinDormitory> cds = checkinDormitoryDao.findBySemesterNameAsType2(condition);
				for (CheckinDormitory cd : cds) {
					Set<Student> students = cd.getStudents();
					for (Student student : students) {
						Banji banji = student.getBanji();
						Teacher head_teacher = banji.getTeacher();
						Dormitory dormitory = student.getDormitory();
						Teacher counselor = dormitory.getTeacher();
						cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd,
								condition.getQuery_type().toString()));
					}
				}
			} else {
				// 无输入学生姓名
				List<CheckinDormitory> cds = checkinDormitoryDao.findBySemesterAsType2(condition);
				for (CheckinDormitory cd : cds) {
					Set<Student> students = cd.getStudents();
					for (Student student : students) {
						Banji banji = student.getBanji();
						Teacher head_teacher = banji.getTeacher();
						Dormitory dormitory = student.getDormitory();
						Teacher counselor = dormitory.getTeacher();
						cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd,
								condition.getQuery_type().toString()));
					}
				}
			}
		}
		return cdrbs;
	}

	@Override
	public List<CheckinDormitoryRecordBean> getCheckinDataAsTeacherType3WithCondition(
			QueryCheckDormitoryCondition condition) {
		List<CheckinDormitoryRecordBean> cdrbs = new ArrayList<>();
		String condition_semester = condition.getSemester();
		String condition_student_name = condition.getStudent_name();
		if (condition.getQuery_type()==1) {
			// 查询日常数据
			if ((condition_student_name != null) && (condition_student_name != "")) {
				// 有输入学生姓名
				List<CheckinDormitory> cds = checkinDormitoryDao.findByTimeBanjiNameAsType3(condition);
				for (CheckinDormitory cd : cds) {
					Set<Student> students = cd.getStudents();
					for (Student student : students) {
						Banji banji = student.getBanji();
						Teacher head_teacher = banji.getTeacher();
						Dormitory dormitory = student.getDormitory();
						Teacher counselor = dormitory.getTeacher();
						cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd,
								condition.getQuery_type().toString()));
					}
				}
			} else {
				// 无输入学生姓名
				List<CheckinDormitory> cds = checkinDormitoryDao.findByTimeBanjiAsType3(condition);
				for (CheckinDormitory cd : cds) {
					Set<Student> students = cd.getStudents();
					for (Student student : students) {
						Banji banji = student.getBanji();
						Teacher head_teacher = banji.getTeacher();
						Dormitory dormitory = student.getDormitory();
						Teacher counselor = dormitory.getTeacher();
						cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd,
								condition.getQuery_type().toString()));
					}
				}
			}

		} else {
			// 查询学期数据
			if ((condition_student_name != null) && (condition_student_name != "")) {
				// 有输入学生姓名
				List<CheckinDormitory> cds = checkinDormitoryDao.findBySemesterNameAsType3(condition);
				for (CheckinDormitory cd : cds) {
					Set<Student> students = cd.getStudents();
					for (Student student : students) {
						Banji banji = student.getBanji();
						Teacher head_teacher = banji.getTeacher();
						Dormitory dormitory = student.getDormitory();
						Teacher counselor = dormitory.getTeacher();
						cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd,
								condition.getQuery_type().toString()));
					}
				}
			} else {
				// 无输入学生姓名
				List<CheckinDormitory> cds = checkinDormitoryDao.findBySemesterAsType3(condition);
				for (CheckinDormitory cd : cds) {
					Set<Student> students = cd.getStudents();
					for (Student student : students) {
						Banji banji = student.getBanji();
						Teacher head_teacher = banji.getTeacher();
						Dormitory dormitory = student.getDormitory();
						Teacher counselor = dormitory.getTeacher();
						cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji, cd,
								condition.getQuery_type().toString()));
					}
				}
			}
		}
		return cdrbs;
	}

	// @Override
	// public List<CheckinDormitoryRecordBean>
	// getCheckinDataAsTeacherType1WithCondition(
	// QueryCheckDormitoryCondition condition) {
	// List<CheckinDormitoryRecordBean> cdrbs = new ArrayList<>();
	// Teacher head_teacher = teacherDao.findById(condition.getTeacher_id());
	// Banji banji = banjiDao.findByName(condition.getBanji_name());
	// String student_name = condition.getStudent_name();
	// if ((student_name != null) && (student_name != "")) {
	// // 班级名，日期，学生名字
	// Student student = studentDao.findByBanjiAndName(student_name, banji);
	// Dormitory dormitory = student.getDormitory();
	// Teacher counselor = dormitory.getTeacher();
	// Set<CheckinDormitory> cds = student.getCheckinDormitories();
	// for (CheckinDormitory cd : cds) {
	// cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji,
	// cd,
	// condition.getIdentity_type().toString()));
	// }
	// } else {
	// // 班级名，日期
	// Set<Student> students = banji.getStudents();
	// for (Student student : students) {
	// Set<Student> condition_student = new HashSet<>();
	// Dormitory dormitory = student.getDormitory();
	// Teacher counselor = dormitory.getTeacher();
	// List<CheckinDormitory> cds =
	// checkinDormitoryDao.findByTimeAndStudent(condition.getTime(),
	// condition_student);
	// for (CheckinDormitory cd : cds) {
	// cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji,
	// cd,
	// condition.getIdentity_type().toString()));
	// }
	// }
	// }
	//
	// return cdrbs;
	// }
	//
	// @Override
	// public List<CheckinDormitoryRecordBean>
	// getCheckinDataAsTeacherType2WithCondition(
	// QueryCheckDormitoryCondition condition) {
	// List<CheckinDormitoryRecordBean> cdrbs = new ArrayList<>();
	// Teacher counselor = teacherDao.findById(condition.getTeacher_id());
	// List<Dormitory> dormitories =
	// dormitoryDao.findByZoom2AndCounselor(condition.getZoom_2(), counselor);
	// for (Dormitory dormitory : dormitories) {
	// List<Student> students = studentDao.findByDormitory(dormitory);
	// for (Student student : students) {
	// Banji banji = student.getBanji();
	// Teacher head_teacher = banji.getTeacher();
	// Set<CheckinDormitory> cds = student.getCheckinDormitories();
	// for (CheckinDormitory cd : cds) {
	// cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji,
	// cd,
	// condition.getIdentity_type().toString()));
	// }
	// }
	// }
	// return cdrbs;
	// }
	//
	// @Override
	// public List<CheckinDormitoryRecordBean>
	// getCheckinDataAsTeacherType3WithCondition(
	// QueryCheckDormitoryCondition condition) {
	// List<CheckinDormitoryRecordBean> cdrbs = new ArrayList<>();
	// Banji banji = banjiDao.findByName(condition.getBanji_name());
	// Teacher head_teacher = banji.getTeacher();
	//
	// String student_name = condition.getStudent_name();
	//
	// if ((student_name != null) && (student_name != "")) {
	// // 班级名，日期，学生名字
	// Student student = studentDao.findByBanjiAndName(student_name, banji);
	// Dormitory dormitory = student.getDormitory();
	// Teacher counselor = dormitory.getTeacher();
	// Set<CheckinDormitory> cds = student.getCheckinDormitories();
	// for (CheckinDormitory cd : cds) {
	// cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji,
	// cd,
	// condition.getIdentity_type().toString()));
	// }
	// } else {
	// // 班级名，日期
	// Set<Student> students = banji.getStudents();
	// for (Student student : students) {
	// Set<Student> condition_student = new HashSet<>();
	// Dormitory dormitory = student.getDormitory();
	// Teacher counselor = dormitory.getTeacher();
	// List<CheckinDormitory> cds =
	// checkinDormitoryDao.findByTimeAndStudent(condition.getTime(),
	// condition_student);
	// for (CheckinDormitory cd : cds) {
	// cdrbs.add(makeCDRB(student, dormitory, counselor, head_teacher, banji,
	// cd,
	// condition.getIdentity_type().toString()));
	// }
	// }
	// }
	// return cdrbs;
	// }

}
